/*
 * CriticalSection.h
 *
 *  Created on: 2012-10-15
 *      Author: tony
 */
#ifndef CRITICALSECTION_H_
#define CRITICALSECTION_H_

#include <windows.h>

class CriticalSection
{
public:
	CriticalSection();
	CriticalSection(DWORD spin_count);
	void Lock(){ EnterCriticalSection(&m_critical_section); }
	void Unlock(){ LeaveCriticalSection(&m_critical_section); }
	virtual ~CriticalSection();

private:
	void Initialize();
	CRITICAL_SECTION m_critical_section;
	DWORD m_spin_count;
};

#endif /* CRITICALSECTION_H_ */
